package com.mokee.android.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mokee.Util.ShipAttrUtil;
import com.mokee.android.Setting.SettingActivity;
import com.mokee.android.SharedPreference.MyValuesInt;
import com.mokee.android.SharedPreference.MyValuesString;
import com.mokee.android.ShipPass.R;

public class MeFragment extends Fragment implements OnClickListener {
	private static final String tag = "MeFragment";
	
	private TextView tv_MeNikeName, tv_MeLoginName, tv_MeShipName,
					 tv_MeShipType, tv_MeShipWeightOri, tv_MeShipRegisterNum;
	private LinearLayout goToSetting;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
		View view = inflater.inflate(R.layout.activity_me, container, false);

		initView(view);
		return view;
	}

	private void initView(View view) {
		goToSetting = (LinearLayout) view.findViewById(R.id.linearLayout_GoToSetting);
		
		tv_MeNikeName = (TextView) view.findViewById(R.id.tv_MeNikeName);
		tv_MeLoginName = (TextView) view.findViewById(R.id.tv_MeLoginName);
		tv_MeShipName = (TextView) view.findViewById(R.id.tv_MeShipName);
		tv_MeShipType = (TextView) view.findViewById(R.id.tv_MeShipType);
		tv_MeShipWeightOri = (TextView) view.findViewById(R.id.tv_MeShipWeightOri);
		tv_MeShipRegisterNum = (TextView) view.findViewById(R.id.tv_MeShipRegisterNum);
		
		tv_MeNikeName.setText(MyValuesString.getNikeName());
		tv_MeLoginName.setText(MyValuesString.getLoginName());
		tv_MeShipName.setText(MyValuesString.getShipName());
		tv_MeShipType.setText(ShipAttrUtil.shipTypeInt2String(MyValuesInt.getShipType()));
		tv_MeShipWeightOri.setText(String.valueOf(MyValuesInt.getShipWeightOri()));
		tv_MeShipRegisterNum.setText(MyValuesString.getRegisterNum());
	}

	@Override
	public void onResume() {
		super.onResume();
		goToSetting.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.linearLayout_GoToSetting:
			Intent settingIntent = new Intent(getActivity(), SettingActivity.class);
			startActivity(settingIntent);
			break;

		default:
			break;
		}
	}
}
